<form id="add-form" class="form-horizontal" role="form" data-toggle="validator" method="POST" action="">

    <div class="form-group">
        <label class="control-label col-xs-12 col-sm-2">{:__('Name')}:</label>
        <div class="col-xs-12 col-sm-8">
            <select  id="c-name" data-rule="required" class="form-control selectpicker" name="row[name]" data-live-search="true" data-show-subtext="true">
                {foreach name="tableList" item="vo"}
                    {if isset($row)}
                        <option data-subtext="{$vo.TABLE_COMMENT}" value="{$vo.TABLE_NAME}" {in name="vo.TABLE_NAME" value="$row.name"}selected{/in}>{$vo.TABLE_NAME}</option>
                    {else}
                        <option data-subtext="{$vo.TABLE_COMMENT}" value="{$vo.TABLE_NAME}">{$vo.TABLE_NAME}</option>
                    {/if}
                {/foreach}
            </select>
        </div>
    </div>
    <div class="form-group">
        <label class="control-label col-xs-12 col-sm-2">{:__('Field_total')}:</label>
        <div class="col-xs-12 col-sm-8">
            <select id="c-field_total" style="height:30px;" name="row[field_total]" data-value="{if isset($row)}{$row.field_total|htmlentities}{/if}" class="form-control selectpicker" data-live-search="true" data-show-subtext="true"></select>
        </div>
    </div>
    <div class="form-group">
        <label class="control-label col-xs-12 col-sm-2">{:__('Field_time')}:</label>
        <div class="col-xs-12 col-sm-8">
            <select id="c-field_time" style="height:30px;" name="row[field_time]" data-value="{if isset($row)}{$row.field_time|htmlentities}{/if}" class="form-control selectpicker" data-live-search="true" data-show-subtext="true"></select>
            <input type="hidden" name="row[field_time_type]" value="{if isset($row)}{$row.field_time|htmlentities}{/if}">
        </div>
    </div>
    <div class="form-group">
        <label class="control-label col-xs-12 col-sm-2">{:__('Group_field')}:</label>
        <div class="col-xs-12 col-sm-8">
            <select id="c-group_field" style="height:30px;" name="row[group_field]" data-value="{if isset($row)}{$row.group_field|htmlentities}{/if}" class="form-control selectpicker" data-live-search="true" data-show-subtext="true"></select>
        </div>
    </div>

    <div class="form-group">
        <label class="control-label col-xs-12 col-sm-2">{:__('选择关联表')}:</label>
        <div class="col-xs-12 col-sm-8">
            <select  id="c-join_table" class="form-control selectpicker" name="row[join_table]" data-live-search="true" data-show-subtext="true">
                <option value="">不关联</option>
                {foreach name="tableList" item="vo"}
                    {if isset($row)}
                        <option data-subtext="{$vo.TABLE_COMMENT}" value="{$vo.TABLE_NAME}" {in name="vo.TABLE_NAME" value="$row.join_table"}selected{/in}>{$vo.TABLE_NAME}</option>
                    {else}
                        <option data-subtext="{$vo.TABLE_COMMENT}" value="{$vo.TABLE_NAME}">{$vo.TABLE_NAME}</option>
                    {/if}
                {/foreach}
            </select>
        </div>
    </div>

    <div class="form-group join_table" style="display: none;">
        <label class="control-label col-xs-12 col-sm-2">{:__('关联外键')}:</label>
        <div class="col-xs-12 col-sm-8">
            <select id="c-foreign_key" style="height:30px;" name="row[foreign_key]" data-value="{if isset($row)}{$row.foreign_key|htmlentities}{/if}" class="form-control selectpicker" data-live-search="true" data-show-subtext="true"></select>
        </div>
    </div>

    <div class="form-group join_table" style="display: none;">
        <label class="control-label col-xs-12 col-sm-2">{:__('关联主键')}:</label>
        <div class="col-xs-12 col-sm-8">
            <select id="c-local_key" style="height:30px;" name="row[local_key]" data-value="{if isset($row)}{$row.local_key|htmlentities}{/if}" class="form-control selectpicker" data-live-search="true" data-show-subtext="true"></select>
        </div>
    </div>

    <div class="form-group join_table" style="display: none;">
        <label class="control-label col-xs-12 col-sm-2">{:__('显示的字段')}:</label>
        <div class="col-xs-12 col-sm-8">
            <select id="c-field_show" style="height:30px;" name="row[field_show]" data-value="{if isset($row)}{$row.field_show|htmlentities}{/if}" class="form-control selectpicker" data-live-search="true" data-show-subtext="true"></select>
        </div>
    </div>

    <div class="form-group dictionary">
        <label class="control-label col-xs-12 col-sm-2">{:__('分组字典')}:</label>
        <div class="col-xs-12 col-sm-8">
            <dl class="fieldlist" data-name="row[dictionary]">
                <dd>
                    <ins>分组字段值</ins>
                    <ins>显示的名称</ins>
                </dd>
                <dd>
                    <a href="javascript:;" class="btn btn-sm btn-success btn-append"><i class="fa fa-plus"></i> 追加</a>
                </dd>
                <textarea name="row[dictionary]" class="form-control hide" cols="30" rows="5">{if isset($row)}{$row.dictionary|htmlentities}{/if}</textarea>
            </dl>
        </div>
    </div>
    
    <div class="form-group">
        <label class="control-label col-xs-12 col-sm-2">{:__('Where')}:</label>
        <div class="col-xs-12 col-sm-8">
            <input id="c-where" class="form-control" name="row[where]" placeholder="如：status='normal' 或 id>10" type="text" value="{if isset($row)}{$row.where|htmlentities}{/if}">
        </div>
    </div>
    <div class="form-group">
        <label class="control-label col-xs-12 col-sm-2">{:__('Type_total')}:</label>
        <div class="col-xs-12 col-sm-8">
            {if isset($row)}
                {:build_radios('row[type_total]', $typeTotalList, $row['type_total'])}
            {else}
                {:build_radios('row[type_total]', $typeTotalList, 'count')}
            {/if}
        </div>
    </div>
    <div class="form-group">
        <label class="control-label col-xs-12 col-sm-2">{:__('Type_time')}:</label>
        <div class="col-xs-12 col-sm-8">
            {if isset($row)}
                {:build_radios('row[type_time]', $typeTimeList, $row['type_time'])}
            {else}
                {:build_radios('row[type_time]', $typeTimeList, 'all')}
            {/if}
        </div>
    </div>
    <div class="form-group">
        <label class="control-label col-xs-12 col-sm-2">{:__('Title')}:</label>
        <div class="col-xs-12 col-sm-8">
            <input id="c-title" data-rule="required" placeholder="如：销量排行榜" class="form-control" name="row[title]" type="text" value="{if isset($row)}{$row.title|htmlentities}{/if}">
        </div>
    </div>
    <div class="form-group">
        <label class="control-label col-xs-12 col-sm-2">{:__('Unit')}:</label>
        <div class="col-xs-12 col-sm-8">
            <input id="c-unit" data-rule="required" placeholder="如：金额、单数、次数等" class="form-control" name="row[unit]" type="text" value="{if isset($row)}{$row.unit|htmlentities}{/if}">
        </div>
    </div>
    <div class="form-group">
        <label class="control-label col-xs-12 col-sm-2">{:__('Show_num')}:</label>
        <div class="col-xs-12 col-sm-8">
            <input id="c-show_num" data-rule="required" placeholder="排行榜显示数量，如前10或前3" class="form-control" name="row[show_num]" type="number" value="{if isset($row)}{$row.show_num|htmlentities}{/if}">
        </div>
    </div>
    <div class="form-group">
        <label class="control-label col-xs-12 col-sm-2">{:__('Weigh')}:</label>
        <div class="col-xs-12 col-sm-8">
            <input id="c-weigh" data-rule="required" class="form-control" name="row[weigh]" type="number" value="{if isset($row)}{$row.weigh|htmlentities}{/if}">
        </div>
    </div>
    <div class="form-group layer-footer">
        <label class="control-label col-xs-12 col-sm-2"></label>
        <div class="col-xs-12 col-sm-8">
            <button type="submit" class="btn btn-success btn-embossed disabled">{:__('OK')}</button>
            <button type="reset" class="btn btn-default btn-embossed">{:__('Reset')}</button>
        </div>
    </div>
</form>